#!/usr/bin/python
# -*- coding: UTF-8 -*-

from tornado.web import RequestHandler
import json as _json


class Hello(RequestHandler):
    "类似与Servlet，一个类相当于一个Servlet，提供Get/Post方法"

    def data_received(self, chunk):
        pass

    def get(self):
        q = self.get_argument("q", "_q")
        print("q: %s" % q)
        self.write("hello get")

    def post(self):
        # 接收form参数
        form = self.get_argument("form", "_default")
        print("from: %s" % form)
        # 接收Json参数
        json = _json.loads(self.request.body)
        print("json: %s" % json)
        self.write("hello post")
